namespace Auditing.Business.DataHandlers
{
    using System;
    using DataAccess.Handlers;
    using System.Reflection;
    using DataAccess;
    using Common;
    using System.Data;

    /// <summary>
    /// usar esta clase en PrePersist
    /// </summary>
    public class HashSetDataHandler : IDataHandler
    {
        public bool Process(object entity, PropertyInfo[] properties, DataRow row, string table)
        {
            if (row == null) return false;

            if (row.Table.Columns.Contains(DataConstants.RowHashColumn))
            {
                int value = IntegrityService.CalcRowHash(row);
                row[DataConstants.RowHashColumn] = value;
            }

            return true;
        }

        public bool Process(object entity, PropertyInfo[] properties, string table)
        {
            return true;
        }
    }
}